{% extends "base.html" %}

{% block title %}视频拍照 - Camera Pi{% endblock %}

{% block sidebar %}
<div class="list-group list-group-flush">
    <a href="/video/monitor" class="list-group-item list-group-item-action">
        <i class="bi bi-camera-video"></i> 视频监控
    </a>
    <a href="/video/capture" class="list-group-item list-group-item-action active">
        <i class="bi bi-camera"></i> 视频拍照
    </a>
    <a href="/video/face" class="list-group-item list-group-item-action">
        <i class="bi bi-person-badge"></i> 人脸识别
    </a>
</div>
{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12 mb-4">
            <h2><i class="bi bi-camera"></i> 视频拍照</h2>
            <p class="lead">拍摄高质量照片</p>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-8">
            <div class="card">
                <div class="card-body">
                    <div class="video-container">
                        <img src="{{ url_for('video_feed') }}" class="img-fluid" alt="视频流">
                    </div>
                </div>
            </div>
        </div>
        
        <div class="col-md-4">
            <div class="card mb-3">
                <div class="card-body">
                    <h5 class="card-title"><i class="bi bi-sliders"></i> 拍照设置</h5>
                    <div class="mb-3">
                        <label class="form-label">分辨率</label>
                        <select class="form-select" id="resolution">
                            <option value="1280x720">1280 x 720</option>
                            <option value="1920x1080">1920 x 1080</option>
                            <option value="2592x1944">2592 x 1944</option>
                        </select>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">照片质量</label>
                        <select class="form-select" id="quality">
                            <option value="high">高质量</option>
                            <option value="medium">中等质量</option>
                            <option value="low">低质量</option>
                        </select>
                    </div>
                    <div class="d-grid gap-2">
                        <button class="btn btn-primary" onclick="capture()">
                            <i class="bi bi-camera"></i> 拍照
                        </button>
                        <button class="btn btn-success" onclick="autoCapture()">
                            <i class="bi bi-clock"></i> 定时拍照
                        </button>
                    </div>
                </div>
            </div>
            
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title"><i class="bi bi-images"></i> 最近照片</h5>
                    <div class="recent-photos">
                        <!-- 这里将通过JavaScript动态加载最近的照片 -->
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_js %}
<script>
function capture() {
    fetch('/capture')
        .then(response => response.text())
        .then(message => {
            alert(message);
            loadRecentPhotos();
        })
        .catch(error => {
            console.error('Error:', error);
            alert('拍照失败，请重试');
        });
}

function autoCapture() {
    const interval = prompt('请输入拍照间隔（秒）：', '60');
    if (interval) {
        // 实现定时拍照功能
    }
}

function loadRecentPhotos() {
    // 加载最近拍摄的照片
}
</script>
{% endblock %} 